//
//  NetworkMgr.h
//  AutoRental
//
//  Created by sanzhang on 1/16/14.
//  Copyright (c) 2014 zuche. All rights reserved.
//

#import <Foundation/Foundation.h>

typedef enum eHttpBodyFormat
{
    HTTP_JSON_BODY,
    HTTP_FORM_DATA_BODY,
}eHttpBodyFormat;


typedef enum eYylFuncID
{
    eAPI_START,                 // 开始
    eAPI_REG,                   // 注册
    eAPI_LOGIN,                 // 登录
    eAPI_UPDATE_MEMBER,         // 更新用户信息
    eAPI_UPLOAD_PHOTO,          // 上传头像
    eAPI_CHANGE_PSD,            // 修改密码
    eAPI_ROOM_LIST,             // 获取房间列表
    eAPI_SEARCH_ROOM,           // 按房间号查询
    eAPI_PRIZE_LIST,            // 读取抽奖列表
    eAPI_PRIZE_LOTTERY,         // 抽奖
    eAPI_PRIZE_INFO,            // 领奖信息设置
    eAPI_RECHARGE,              // 充值
    eAPI_SHARE,                 // 分享
    eAPI_VERSION                // 版本
    
}eYylFuncID;


#define kHTTPCallbackDelegate	@"kHTTPCallbackDelegate"

// network
@class ASINetworkQueue;
@class ASIHTTPRequest;
@class ASIFormDataRequest;

@class NetworkMgr;

@protocol NetworkDelegate
@optional
- (void) didSuccess:(NetworkMgr *)api userInfo:(NSDictionary *)info;
- (void) didFail:(NetworkMgr *)api userInfo:(NSDictionary *)info;
- (void) didCancelNetwork:(NetworkMgr *)api;
@end

@interface NetworkMgr : NSObject

@property (assign) id<NetworkDelegate>      delegate;

@property (strong) ASIHTTPRequest           *asynchRequest;
@property (strong) ASIFormDataRequest       *formDataRequest;

@property (strong) ASINetworkQueue *networkQueue;

@property (strong) NSMutableArray  *requestItems;

@property (strong) NSString *userID;

+ (id)sharedManager;
+ (NSString *)clientID;
- (NSString *)generalParams;

- (void)asynchRequestWithFunId:(eYylFuncID)funId delegate:(id)del params:(NSDictionary *)params;
- (void)cancelAsynRequest;

- (void) requestInQueueWithFunId:(eYylFuncID)funId delegate:(id)del params:(NSDictionary *)params;
- (void) startQueueRequest;
- (void) cancelQueueRequest;

//- (void)asynchRequestRetry;

- (BOOL)isReachable;//判断网络是否可用

@end


